package com.example.tool.bean;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;


public class UserEntity implements Parcelable {
    private boolean uiSelect;

    /**
     * address : string
     * birthday : string
     * certificate : string
     * id : 0
     * isDefault : 0
     * isHealth : 0
     * name : string
     * nation : string
     * phone : string
     * relationId : 0
     * relationship : string
     * sex : 0
     * token : string
     * type : 0
     * typeName : string
     */

    private String address;
    private String birthday;
    private String certificate;
    private long id;
    private int isDefault;
    private int isHealth;
    private int isMedicalCard;
    private String name;
    private int nationId;
    private String nation;
    private String phone;
    private int relationId;
    private long memberId;
    private String relationship;
    private int sex;
    private String token;
    private int type;
    private String typeName;

    public UserEntity() {
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    public String getCertificate() {
        return certificate;
    }

    public void setCertificate(String certificate) {
        this.certificate = certificate;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public int getIsDefault() {
        return isDefault;
    }

    public void setIsDefault(int isDefault) {
        this.isDefault = isDefault;
    }

    public int getIsHealth() {
        return isHealth;
    }

    public boolean hasHealthCode() {
        return isHealth != 0;
    }

    public boolean hasMedicalCard() {
        return isMedicalCard != 0;
    }

    public void setIsHealth(int isHealth) {
        this.isHealth = isHealth;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getNationId() {
        return nationId;
    }

    public void setNationId(int nationId) {
        this.nationId = nationId;
    }

    public String getNation() {
        return nation;
    }

    public void setNation(String nation) {
        this.nation = nation;
    }

    public long getMemberId() {
        return memberId;
    }

    public void setMemberId(long memberId) {
        this.memberId = memberId;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public int getRelationId() {
        return relationId;
    }

    public boolean isRelationSelf() {
        //对应后端硬编码-个人关系17
        return relationId == 17;
    }

    public boolean isInfoComplete() {
        return !TextUtils.isEmpty(name) && !TextUtils.isEmpty(certificate);
    }


    public void setRelationId(int relationId) {
        this.relationId = relationId;
    }

    public String getRelationship() {
        return relationship;
    }

    public void setRelationship(String relationship) {
        this.relationship = relationship;
    }

    public int getSex() {
        return sex;
    }

    public void setSex(int sex) {
        this.sex = sex;
    }


    public String getSexString() {
        if (sex == 1) {
            return "男";
        } else if (sex == 2) {
            return "女";
        } else {
            return "";
        }
    }

    public static String getSexString(int sex) {
        if (sex == 1) {
            return "男";
        } else if (sex == 2) {
            return "女";
        } else {
            return "";
        }
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public int getIsMedicalCard() {
        return isMedicalCard;
    }

    public void setIsMedicalCard(int isMedicalCard) {
        this.isMedicalCard = isMedicalCard;
    }

    public boolean isUiSelect() {
        return uiSelect;
    }

    public UserEntity setUiSelect(boolean uiSelect) {
        this.uiSelect = uiSelect;
        return this;
    }


    protected UserEntity(Parcel in) {
        uiSelect = in.readByte() != 0;
        address = in.readString();
        birthday = in.readString();
        certificate = in.readString();
        id = in.readLong();
        memberId = in.readLong();
        isDefault = in.readInt();
        isHealth = in.readInt();
        isMedicalCard = in.readInt();
        name = in.readString();
        nation = in.readString();
        nationId = in.readInt();
        phone = in.readString();
        relationId = in.readInt();
        relationship = in.readString();
        sex = in.readInt();
        token = in.readString();
        type = in.readInt();
        typeName = in.readString();
    }

    public static final Creator<UserEntity> CREATOR = new Creator<UserEntity>() {
        @Override
        public UserEntity createFromParcel(Parcel in) {
            return new UserEntity(in);
        }

        @Override
        public UserEntity[] newArray(int size) {
            return new UserEntity[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeByte((byte) (uiSelect ? 1 : 0));
        dest.writeString(address);
        dest.writeString(birthday);
        dest.writeString(certificate);
        dest.writeLong(id);
        dest.writeLong(memberId);
        dest.writeInt(isDefault);
        dest.writeInt(isHealth);
        dest.writeInt(isMedicalCard);
        dest.writeString(name);
        dest.writeString(nation);
        dest.writeInt(nationId);
        dest.writeString(phone);
        dest.writeInt(relationId);
        dest.writeString(relationship);
        dest.writeInt(sex);
        dest.writeString(token);
        dest.writeInt(type);
        dest.writeString(typeName);
    }

    @Override
    public String toString() {
        return "UserEntity{" +
                "uiSelect=" + uiSelect +
                ", address='" + address + '\'' +
                ", birthday='" + birthday + '\'' +
                ", certificate='" + certificate + '\'' +
                ", id=" + id +
                ", memberId=" + memberId + '\'' +
                ", isDefault=" + isDefault + '\'' +
                ", isHealth=" + isHealth + '\'' +
                ", isMedicalCard=" + isMedicalCard + '\'' +
                ", name='" + name + '\'' +
                ", nationId=" + nationId +
                ", nation='" + nation + '\'' +
                ", phone='" + phone + '\'' +
                ", relationId=" + relationId +
                ", relationship='" + relationship + '\'' +
                ", sex=" + sex +
                ", token='" + token + '\'' +
                ", type=" + type +
                ", typeName='" + typeName + '\'' +
                '}';
    }
}
